#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>

void merge(int* nums1, int nums1Size, int m, int* nums2, int nums2Size, int n)
{
    int right1 = m - 1;
    int right2 = n - 1;
    int right_sum = n + m - 1;
    while (right1 != -1 && right2 != -1)
    {
        if (nums1[right1] <= nums2[right2])
        {
            nums1[right_sum] = nums2[right2];
            right_sum--;
            right2--;
        }
        else
        {
            nums1[right_sum] = nums1[right1];
            right_sum--;
            right1--;
        }
    }
    while (right_sum != -1)
    {
        if(right1 == -1)
        {
            nums1[right_sum] = nums2[right2];
            right_sum--;
            right2--;
        }
        else
        {
            nums1[right_sum] = nums1[right1];
            right_sum--;
            right1--;
        }
    }
}

int main()
{
    int nums1[] = { 1,2,3,0,0,0 };
    int nums2[] = { 2,5,6 };
    merge(nums1, 6, 3, nums2, 3, 3);
    return 0;
}